{% load static %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="{% static 'layui/css/layui.css' %}" rel="stylesheet" media="all">
</head>
<body>
<style>
    .demo-login-container {
        width: 320px;
        margin: 21px auto 0;
    }

    .demo-login-other .layui-icon {
        position: relative;
        display: inline-block;
        margin: 0 2px;
        top: 2px;
        font-size: 26px;
    }

    #bg {
        width: 24%;
        height: 500px;
        margin: 100px auto;
        border-color: black;
        border-width: 2px;
        border-radius: 15px;
        border: 1px solid #000000;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        padding: 10px;
        text-align: center;
        line-height: 80px;

    }
</style>
<div id="bg">
    <h1 style="text-align: center">注册</h1>
    <form class="layui-form" method="post" novalidate>
        {% csrf_token %}
        <div class="demo-login-container">
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-username"></i>
                    </div>
                    {{ form.username }}
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    {{ form.password }}
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-wrap">
                    <div class="layui-input-prefix">
                        <i class="layui-icon layui-icon-password"></i>
                    </div>
                    {{ form.confirm_password }}
                </div>
            </div>

            <div class="layui-form-item">
                <button type="submit" class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">注册</button>
            </div>
        </div>
    </form>
</div>


<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="{% static 'layui/layui.js' %}"></script>
<script>
    layui.use(function () {
        var layer = layui.layer
        {% for msg in messages %}
            var iconValue = "{{msg.tags}}" == 'success' ? 1 : 2;
            layer.msg(
                '{{ msg }}',
                {icon: iconValue, time: 2000},
                function () {
                    if (iconValue === 1) {
                        window.location.href = '{% url 'login:登录' %}';
                    }
                }
            );
        {% endfor %}

    })

</script>

</body>
</html>